Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds JWT validity checking functionality to the JWT parser utility. It displays a color-coded status message indicating whether a token is valid, expired, not yet valid, or never valid based on the iat, nbf, and exp claims.
Changes:
- Added validity checking logic that evaluates JWT timestamp claims (
iat,nbf,exp) - Integrated a visual validity indicator with color-coded backgrounds in the JWT parser UI
- Added comprehensive unit tests for the new validity checking functionality
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| tailwind.config.ts | Added safelist for dynamic color classes used in validity status display |
| pages/utilities/jwt-parser.tsx | Integrated validity state and color-coded UI component |
| components/utils/jwt-parser.utils.ts | Implemented validity checking logic with date parsing and state enum |
| components/utils/jwt-parser.utils.test.ts | Added comprehensive tests for new validity checking functions |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| }; | ||
| else | ||
| return { | ||
| message: "Token doesn`t contain a validity period", |
There was a problem hiding this comment.
Incorrect apostrophe character used. The message uses a backtick (`) instead of a proper apostrophe ('). This should be "Token doesn't contain a validity period" with a straight apostrophe.
| message: "Token doesn`t contain a validity period", | |
| message: "Token doesn't contain a validity period", |
| admin: true, | ||
| }); | ||
| expect(result.signature).toBe("abc123"); | ||
| expect(result.payload).toEqual({ |
There was a problem hiding this comment.
Test assertion is checking the wrong property. Line 161 should be checking result.validity instead of result.payload. The assertion on line 155-159 already verifies the payload content, and this line should verify the validity property that was added to the return type.
| expect(result.payload).toEqual({ | |
| expect(result.validity).toEqual({ |
| @@ -46,6 +158,10 @@ describe("decodeJWT", () => { | |||
| admin: true, | |||
There was a problem hiding this comment.
The expected payload is missing the 'iat' field that was added to the test token on line 141. The assertion should include iat: "10000" to match the actual payload structure being tested.
| admin: true, | |
| admin: true, | |
| iat: "10000", |
Hi,
this PR introduces a quick info, whether a jwt is currently valid. I would love to get feedback on this, especially on my wording; and if you determine it as good enough, I would be happy to see it merged.